package crossCount;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import _general.geometry.Edge;
import _general.geometry.Node;
import _general.geometry.Point;
import _general.problem.CrossCount;

public class BruteForce extends CrossCount {

	@Override
	public void start() {
		
		List<Edge> _e = new ArrayList<Edge>();
		for (Iterator<Point> i = pointSet.iterator(); i.hasNext();) {
			Point p = i.next();
			
			if (p.getClass().equals(Node.class) && ((Node) p).isStart()) {
				_e.add(((Node) p).getEdge());
			}
		}
		
		for (int i = 0; i < _e.size(); i++) {
			Edge comparedEdge = _e.get(i);
			for (int j = i + 1; j < _e.size(); j++) {
				if (comparedEdge.isIntersection(_e.get(j)))
					crossCount++;
			}
		}
		
		System.out.println("Brute Force:\t\t counted intersections: " + crossCount);

	}
}
